/*
 *  FILE: 
 *  	string.h
 *
 *  DESCRIPTION:
 *      Simple case-insensitive string compare, along with 
 *  	an implementation of OpenBSD's strlcpy and strlcat.
 *
 *  FUNCTIONS:
 *      string_cmp() - Simple case-insensitive string compare.
 *  	strlcpy()    - Implementation of OpenBSD's strlcpy.
 *  	strlcat()    - Implementation of OpenBSD's strlcat.
 *
 *
 * Copyright (c) 2004-2006 Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *         This product includes software developed by
           Karlan Thomas Mitchell<karlanmitchell@gmail.com>
 * 4. Neither Karlan Thomas Mitchell nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY KARLAN THOMAS MITCHELL AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __CUSTOM_STRING
#define __CUSTOM_STRING

#include <ctype.h> /*tolower/toupper*/
#include <stdio.h> /*pretty much just size_t, and snprintf*/
#include <string.h> /*strlenf*/
#include <stdlib.h> /*off_t*/


#ifdef _LARGEFILE_SOURCE
	#ifndef atooff_t
	#define atooff_t atoll
	#endif
#else
	#ifndef atooff_t
	#define atooff_t atol
	#endif
#endif


int str_splitup(char *header, char * name, size_t namelen, char * value, size_t valuelen, char * separators);
void string_to_upper(char * string);
void string_to_lower(char * string);
int signed string_cmp(char * s1, char * s2);
void strcreplace(char * string, char what, char with);
void strstrreplace(char * string, size_t string_len, char * what, char * with);

/*
TODO: Remove out of official code...

decode_range:
	This functions takes in the value of the HTTP range header
	skips the 'bytes=' and
*/
int decode_range(char * client_range, off_t max, off_t * seek_pos, off_t * end_pos);


#ifndef __BSDSYSTEM__
size_t strlcpy(char * dst, const char * src, size_t size);
size_t strlcat(char * dst, const char * src, size_t size);
#endif

#endif
